package com.zx.mvcframework.handle;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @ProjectName: myspring
 * @Package: com.zx.mvcframework.handle
 * @ClassName: HandlerMapping
 * @Author:
 * @Description: 1
 * @Date: 2021/10/4 18:29
 */
public class HandlerMapping {

    private Pattern pattern; // spring中url是支持正则的

    private HandlerExecutionChain  handlerExecutionChain;

    public HandlerMapping(Pattern pattern,HandlerExecutionChain handlerExecutionChain){
        this.pattern = pattern;
        this.handlerExecutionChain = handlerExecutionChain;
    }

    /**
     *  判断路径是否匹配
     */
    public boolean urlMatcher(HttpServletRequest req){
      return   this.pattern.matcher(req.getRequestURI()).matches();
    }
    /**
     * 返回处理链
     */
    public HandlerExecutionChain getHandlerExecutionChain()  {
            return this.handlerExecutionChain;
    }

}
